home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / qwakprot.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  3KB  |  137 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12.  
  13. static struct rectangle spritevisiblearea =
  14. {
  15.     1*8, 31*8-1,
  16.     0*8, 30*8-1
  17. };
  18.  
  19.  
  20. /***************************************************************************
  21.   qwakprot_paletteram_w
  22.  
  23.   This might seem a little odd, but it really seems as though the palette
  24.   is writing as GGGRRRBB.  This is just a guess, and has not been confirmed.
  25. ***************************************************************************/
  26. WRITE_HANDLER( qwakprot_paletteram_w )
  27. {
  28.     int bit0,bit1,bit2;
  29.     int r,g,b;
  30.  
  31.  
  32.     paletteram[offset] = data;
  33.  
  34.     /* red component */
  35.     bit0 = (~data >> 2) & 0x01;
  36.     bit1 = (~data >> 3) & 0x01;
  37.     bit2 = (~data >> 4) & 0x01;
  38.     r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  39.  
  40.     /* green component */
  41.     bit0 = (~data >> 5) & 0x01;
  42.     bit1 = (~data >> 6) & 0x01;
  43.     bit2 = (~data >> 7) & 0x01;
  44.     g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  45.  
  46.     /* blue component */
  47.     bit0 = 0;
  48.     bit1 = (~data >> 0) & 0x01;
  49.     bit2 = (~data >> 1) & 0x01;
  50.     b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  51.  
  52.     palette_change_color(offset,r,g,b);
  53. }
  54.  
  55.  
  56. /***************************************************************************
  57.  
  58.   Draw the game screen in the given osd_bitmap.
  59.   Do NOT call osd_update_display() from this function, it will be called by
  60.   the main emulation engine.
  61.  
  62. ***************************************************************************/
  63. void qwakprot_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  64. {
  65.     int offs;
  66.  
  67.     if (palette_recalc() || full_refresh)
  68.         memset (dirtybuffer, 1, videoram_size);
  69.  
  70.     for (offs = videoram_size - 1;offs >= 0;offs--)
  71.     {
  72.         if (dirtybuffer[offs])
  73.         {
  74.             int sx,sy;
  75.             int gfxset;
  76.  
  77.  
  78.             dirtybuffer[offs] = 0;
  79.  
  80.             sx = offs % 32;
  81.             sy = offs / 32;
  82.  
  83.             gfxset = ((videoram[offs] & 0x80) >> 7);
  84.             drawgfx(bitmap,Machine->gfx[gfxset],
  85.                     videoram[offs] & 0x7f,
  86.                     0,        /* color */
  87.                     0,0,    /* flipx, flipy */
  88.                     8*sx,8*sy,
  89.                     &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  90.         }
  91.     }
  92.  
  93.     /* Draw the sprites */
  94.     for (offs = 0;offs < 0x10;offs++)
  95.     {
  96.         int spritenum;
  97.         int flip;
  98.         int x, y;
  99.         int sx, sy;
  100.  
  101.         spritenum = spriteram[offs] & 0x7f;
  102.  
  103.         flip = (spriteram[offs] & 0x80);
  104.         x = spriteram[offs + 0x20];
  105.         y = 240 - spriteram[offs + 0x10];
  106.  
  107.         drawgfx(bitmap,Machine->gfx[2],
  108.                 spritenum,0,
  109.                 0,flip,
  110.                 x,y,
  111.                 &spritevisiblearea,TRANSPARENCY_PEN,0);
  112.  
  113.         /* mark tiles underneath as dirty */
  114.         sx = x >> 3;
  115.         sy = y >> 3;
  116.  
  117.         {
  118.             int max_x = 1;
  119.             int max_y = 2;
  120.             int x2, y2;
  121.  
  122.             if (x & 0x07) max_x ++;
  123.             if (y & 0x0f) max_y ++;
  124.  
  125.             for (y2 = sy; y2 < sy + max_y; y2 ++)
  126.             {
  127.                 for (x2 = sx; x2 < sx + max_x; x2 ++)
  128.                 {
  129.                     if ((x2 < 32) && (y2 < 30) && (x2 >= 0) && (y2 >= 0))
  130.                         dirtybuffer[x2 + 32*y2] = 1;
  131.                 }
  132.             }
  133.         }
  134.  
  135.     }
  136. }
  137.